package org.example.prototypePattern;

import lombok.Data;

/**
 * @BelongsProject: javaFoundation
 * @BelongsPackage: org.example.prototypePattern
 * @Author: dtq
 * @CreateTime: 2023-12-14  16:39
 * @Description: TODO
 * @Version: 1.0
 */
@Data
public class StudentSecond implements Cloneable{
    private String idNo;
    private String name;
    private TeacherSecond teacherSecond;

    @Override
    public StudentSecond clone() {
        try {
            StudentSecond clone = (StudentSecond) super.clone();
            // 获得原来的 teacher 对象，并clone出一个新的teacher对象
            TeacherSecond newTeacher = clone.getTeacherSecond().clone();
            // 重新设置teacher
            clone.setTeacherSecond(newTeacher);
            return clone;
        } catch (CloneNotSupportedException e) {
            throw new AssertionError();
        }
    }
}
